package com.ymatou.iapi.login.testcase;

import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.login.parameter.WeiXinUserRequestDtoBean;
import com.ymatou.iapi.login.service.WeiXinUserRequestDtoCall;
import com.ymatou.iapi.userservice.parameter.enums.AppSourceEnum;
import com.ymatou.iapi.userservice.parameter.enums.TerminalSourceEnum;
import com.ymatou.iapi.userservice.parameter.enums.ThirdPartyTypeEnum;
import com.ymatou.iapi.userservice.parameter.req.BindThirdPartyUserReq;
import com.ymatou.iapi.userservice.parameter.req.CreateUserReq;
import com.ymatou.iapi.userservice.parameter.req.UnBindThirdPartyUserReq;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.database.model.LoginLog;
import com.ymttest.database.model.ThirdpartyUserbind;
import com.ymttest.database.model.ThirdpartyUserbindHistory;
import com.ymttest.database.sqlwapper.JUserWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.constant.AppTypeChannel;
import com.ymttest.utils.constant.ECode;
/**
*创建YMT微信用户接口
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_WeiXinUserRequestDto{
	private static WeiXinUserRequestDtoBean regBean;
	private static WeiXinUserRequestDtoCall regCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("微信用户注册 ");
	}

	@Before
	public void caseUp() throws Exception {
		regBean = new WeiXinUserRequestDtoBean();
		regCall = new WeiXinUserRequestDtoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(regCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	private void verifyDBBind(Integer uid, WeiXinUserRequestDtoBean cq) {
		//TODO 需要检查字段
		JUserWapper ju=new JUserWapper();
		
		Logger.comment("验证thirdparty_userbind");
		ThirdpartyUserbind thirdinfo = ju.selectthirdpartyuserbind(uid).get(0);
		Logger.verifyEquals(cq.getUnionId(), thirdinfo.getThirdPartyId(), "验证ThirdPartyId");
		Logger.verifyEquals(ThirdPartyTypeEnum.WeiXin.getCode(), thirdinfo.getThirdPartyType(), "验证ThirdPartyType");
	}
	private void verifyDB(Integer uid, WeiXinUserRequestDtoBean cq) {
		//TODO 需要检查字段
		JUserWapper ju=new JUserWapper();
		
		Logger.comment("验证thirdparty_userbind");
		ThirdpartyUserbind thirdinfo = ju.selectthirdpartyuserbind(uid).get(0);
		Logger.verifyEquals(cq.getUnionId(), thirdinfo.getThirdPartyId(), "验证ThirdPartyId");
		Logger.verifyEquals(ThirdPartyTypeEnum.WeiXin.getCode(), thirdinfo.getThirdPartyType(), "验证ThirdPartyType");
		
		Logger.comment("验证thirdparty_userbind_history");
		ThirdpartyUserbindHistory thirdinfohist = ju.selectthirdpartyuserbindhistory(uid).get(0);
		Logger.verifyEquals(true, thirdinfohist.getBinding(), "验证binding状态");
		Logger.verifyEquals(cq.getRegSource().getCode(), thirdinfohist.getAppSource(), "验证AppSource");
		Logger.verifyEquals(cq.getClientIp(), thirdinfohist.getClientIp(), "验证ClientIp");
		Logger.verifyEquals(cq.getDeviceId(), thirdinfohist.getDeviceId(), "验证DeviceId");
		Logger.verifyEquals(cq.getEquimentid(), thirdinfohist.getEquimentid(), "验证Equimentid");
		Logger.verifyEquals(cq.getMobile(), thirdinfohist.getLoginMobile(), "验证LoginMobile");
		Logger.verifyEquals(cq.getTSource().getCode(), thirdinfohist.getTerminalSource(), "验证TerminalSource");
		
		Logger.verifyEquals(cq.getCity(), thirdinfohist.getCity(), "验证City");
		Logger.verifyEquals(cq.getProvince(), thirdinfohist.getProvince(), "验证City");
		Logger.verifyEquals(cq.getCountry(), thirdinfohist.getCountry(), "验证Country");
		
		Logger.verifyEquals(cq.getOId(), thirdinfohist.getOpenId(), "验证OpenId");
		Logger.verifyEquals(cq.getHeadimgurl(), thirdinfohist.getHeadimgurl(), "验证Headimgurl");
	}
	
//	1.第三方联合登入时传入新的第三方账号且传入手机号为新用户,注册第三方成功

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_001() {
		Logger.start(true,"微信第一次授权,创建用户成功");
		try {
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			String phone = TestDataManager.getPhoneNum();
			Logger.comment("绑定手机号，注册微信");
			regBean.setClientPort("33333");
			regBean.setUnionId(wxId);
			regBean.setName("regwx_"+TestDataManager.getRandomNum(6));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setMobile(phone);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regBean.setDeviceId(TestDataManager.getRandomUUID().toString());
			regBean.setEquimentid(TestDataManager.getRandomUUID().toString());
			regBean.setTokenSource("tokenSource");
//			regBean.setTSource(TerminalSourceEnum.PC);
			regBean.setCountry("Country");
			regBean.setProvince("Province");
			regBean.setCity("City");
			regBean.setHeadimgurl("Headimgurl");
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setDeviceId(TestDataManager.getRandomUUID().toString());
			regCall.setData(regBean);
			regCall.callService();	
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			Integer uid=regCall.getJsonObject().get("Result").getAsJsonObject().get("UserId").getAsInt();
			Logger.comment("和数据库进行数据校验");
			verifyDB(uid,regBean);
			LoginLog loginLog = new JUserWapper().selectLastLoginLogByUid(uid).get(0);
			Logger.verifyEquals(regBean.getName(), loginLog.getLoginId(), "验证LoginLog表中LoginId");
			Logger.verifyEquals(regBean.getClientIp(), loginLog.getClientIp(), "验证LoginLog表中ClientIp");
			// 码头登陆的为0
			Logger.verifyEquals(6, loginLog.getChannelSource(), "验证LoginLog表中ChannelSource");
			Logger.verifyEquals(2, loginLog.getTerminalSource(), "验证LoginLog表中TerminalSource");
			Logger.verifyEquals(regBean.getDeviceId(), loginLog.getDeviceId(), "验证LoginLog表中DeviceId");
			Logger.verifyNotNull(loginLog.getServerIP(), "验证LoginLog表中ServerIP");

			if (regCall.getString("Success").equals("true")) {
				Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(200, loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			} 
			// 风控返回
//			 Logger.verifyNotNull(loginLog.getIpArea(), "验证LoginLog表中IpArea");
			Logger.verifyNotNull(loginLog.getCreateTime(), "验证LoginLog表中CreateTime");
			Logger.verifyEquals(0, loginLog.getUserType(), "验证LoginLog表中UserType");
			Logger.verifyEquals(regBean.getClientPort(), loginLog.getClientPort(), "验证LoginLog表中getClientPort");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	2.第三方联合登入时传入新的第三方账号且传入手机号为码头已存在用户,这个用户没有绑定过对应第三方账号,绑定成功
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_002() {
		Logger.start(true,"第三方联合登入时传入新的第三方账号且传入手机号为码头已存在用户,这个用户没有绑定过对应第三方账号,绑定成功");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			
			regBean.setMobile(cur.getMobile());
			regBean.setUnionId(wxId);
			regBean.setName("Lily"+TestDataManager.getRandomNum(10));
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setClientIp("120.1.1.1");
			
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();			
			Logger.verifyEquals("login", regCall.getResult().get("Remark"), "验证Remark信息");
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			verifyDBBind(uid,regBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	3.第三方联合登入时传入新的第三方账号且传入手机号为码头已存在用户,这个用户绑定过对应第三方账号,失败
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_003() {
		Logger.start(true,"第三方联合登入时传入新的第三方账号且传入手机号为码头已存在用户,这个用户绑定过对应第三方账号,失败");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			BindThirdPartyUserReq third=JUserCallService.initBindThirdUserReq(uid);
			third.setThirdPartyType(ThirdPartyTypeEnum.WeiXin);
			JUserCallService.bindThirdPartyUserCall(third);
			
			regBean.setMobile(cur.getMobile());
			regBean.setUnionId(wxId);
			regBean.setName("Lily"+TestDataManager.getRandomNum(10));
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();			
			Logger.verifyIsContains("该手机号码已经绑定过微信", regCall.getString("LastErrorMessage"), "验证返回的LastErrorMessage信息");
			Logger.verifyEquals("400" ,regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("false", regCall.getString("Success"), "验证是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

//	4.三方联合登入时传入已存在未解绑第三方账号,码头用户手机为空,来源为WAP,需要绑定手机
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_004() {
		Logger.start(true,"三方联合登入时传入已存在未解绑第三方账号,码头用户手机为空,来源为WAP,需要绑定手机");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			cur.setMobile(null);
			int uid = JUserCallService.createUserCall(cur);
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			BindThirdPartyUserReq third=JUserCallService.initBindThirdUserReq(uid);
			third.setThirdPartyType(ThirdPartyTypeEnum.WeiXin);
			JUserCallService.bindThirdPartyUserCall(third);
			
			regBean.setUnionId(wxId);
			regBean.setName("Lily"+TestDataManager.getRandomNum(10));
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.Wap);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();	
			
			Logger.verifyIsContains("为了您的账户安全，请绑定你的手机号码", regCall.getString("LastErrorMessage"), "验证返回的LastErrorMessage信息");
			Logger.verifyEquals("400" ,regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("false", regCall.getString("Success"), "验证是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	5.三方联合登入时传入已存在未解绑第三方账号,码头用户手机为空,来源为非WAP(app),登入成功
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_005() {
		Logger.start(true,"三方联合登入时传入已存在未解绑第三方账号,码头用户手机为空,来源为非WAP(app),登入成功");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			cur.setMobile(null);
			int uid = JUserCallService.createUserCall(cur);
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			BindThirdPartyUserReq third=JUserCallService.initBindThirdUserReq(uid);
			third.setThirdPartyId(wxId);
			third.setThirdPartyType(ThirdPartyTypeEnum.WeiXin);
			JUserCallService.bindThirdPartyUserCall(third);
			
			regBean.setUnionId(wxId);
			regBean.setName("Lily"+TestDataManager.getRandomNum(10));
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();			
			
			Logger.verifyIsContains("登录成功", regCall.getString("SuccessMessage"), "验证返回的SuccessMessage信息");
			Logger.verifyEquals("200" ,regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	6.三方联合登入时传入已存在未解绑第三方账号,码头用户手机和传入手机号一致,登入成功
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_006() {
		Logger.start(true,"三方联合登入时传入已存在未解绑第三方账号,码头用户手机和传入手机号一致,登入成功");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			BindThirdPartyUserReq third=JUserCallService.initBindThirdUserReq(uid);
			third.setThirdPartyId(wxId);
			third.setThirdPartyType(ThirdPartyTypeEnum.WeiXin);
			JUserCallService.bindThirdPartyUserCall(third);
			
			regBean.setMobile(cur.getMobile());
			regBean.setUnionId(wxId);
			regBean.setName("Lily"+TestDataManager.getRandomNum(10));
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();			
			
			Logger.verifyIsContains("登录成功", regCall.getString("SuccessMessage"), "验证返回的SuccessMessage信息");
			Logger.verifyEquals("200" ,regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	7.三方联合登入时传入已存在未解绑第三方账号,码头用户手机为空,第三方传入新手机号,绑定登入成功
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_007() {
		Logger.start(true,"三方联合登入时传入已存在未解绑第三方账号,码头用户手机为空,第三方传入新手机号,绑定登入成功");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			cur.setMobile(null);
			int uid = JUserCallService.createUserCall(cur);
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			BindThirdPartyUserReq third=JUserCallService.initBindThirdUserReq(uid);
			third.setThirdPartyId(wxId);
			third.setThirdPartyType(ThirdPartyTypeEnum.WeiXin);
			JUserCallService.bindThirdPartyUserCall(third);
			
			regBean.setMobile(TestDataManager.getPhoneNum());
			regBean.setUnionId(wxId);
			regBean.setName("Lily"+TestDataManager.getRandomNum(10));
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();			
			
			Logger.verifyIsContains("登录成功", regCall.getString("SuccessMessage"), "验证返回的SuccessMessage信息");
			Logger.verifyEquals("200" ,regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	8.三方联合登入时传入已存在未解绑第三方账号,码头用户手机为空,第三方传入手机号是已存在码头用户,失败
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_008() {
		Logger.start(true,"三方联合登入时传入已存在未解绑第三方账号,码头用户手机为空,第三方传入手机号是已存在码头用户,失败");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			cur.setMobile(null);
			int uid = JUserCallService.createUserCall(cur);
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			BindThirdPartyUserReq third=JUserCallService.initBindThirdUserReq(uid);
			third.setThirdPartyId(wxId);
			third.setThirdPartyType(ThirdPartyTypeEnum.WeiXin);
			JUserCallService.bindThirdPartyUserCall(third);
			
			CreateUserReq cur2 = new CreateUserReq();
			cur2 = JUserCallService.initCreateUserBean(cur2);
			 JUserCallService.createUserCall(cur2);
			
			regBean.setMobile(cur2.getMobile());
			regBean.setUnionId(wxId);
			regBean.setName("Lily"+TestDataManager.getRandomNum(10));
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();			
			
			Logger.verifyIsContains("该手机号码已经绑定过码头账号了，换一个试试吧~", regCall.getString("LastErrorMessage"), "验证返回的LastErrorMessage信息");
			Logger.verifyEquals("400" ,regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("false", regCall.getString("Success"), "验证是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	9.三方联合登入时传入已存在已解绑第三方账号,第三方手机号是新手机,注册登入成功
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_009() {
		Logger.start(true,"三方联合登入时传入已存在已解绑第三方账号,第三方手机号是新手机,注册登入成功");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			BindThirdPartyUserReq third=JUserCallService.initBindThirdUserReq(uid);
			third.setThirdPartyType(ThirdPartyTypeEnum.WeiXin);
			JUserCallService.bindThirdPartyUserCall(third);
			UnBindThirdPartyUserReq ubtrd=new UnBindThirdPartyUserReq();
			ubtrd.setThirdPartyId(third.getThirdPartyId());
			ubtrd.setUserId(uid);
			ubtrd.setThirdPartyType(ThirdPartyTypeEnum.WeiXin);
			JUserCallService.UnBindThirdPartyUserCall(ubtrd);
			
			regBean.setMobile(TestDataManager.getPhoneNum());
			regBean.setUnionId(wxId);
			regBean.setName("Lily"+TestDataManager.getRandomNum(10));
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();
			int nuid=regCall.getJsonObject().get("Result").getAsJsonObject().get("UserId").getAsInt();
			Logger.verifyEquals("new", regCall.getResult().get("Remark"), "验证Remark信息");
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			verifyDBBind(nuid,regBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	10.三方联合登入时传入已存在已解绑第三方账号,第三方手机号是码头已存在未绑定第三方手机号,绑定成功
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_010() {
		//绑定解绑再绑定
		Logger.start(true,"三方联合登入时传入已存在已解绑第三方账号,第三方手机号是码头已存在未绑定第三方手机号,绑定成功");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			BindThirdPartyUserReq third=JUserCallService.initBindThirdUserReq(uid);
			third.setThirdPartyType(ThirdPartyTypeEnum.WeiXin);
			JUserCallService.bindThirdPartyUserCall(third);
			UnBindThirdPartyUserReq ubtrd=new UnBindThirdPartyUserReq();
			ubtrd.setThirdPartyId(third.getThirdPartyId());
			ubtrd.setUserId(uid);
			ubtrd.setThirdPartyType(ThirdPartyTypeEnum.WeiXin);
			JUserCallService.UnBindThirdPartyUserCall(ubtrd);
			
			regBean.setMobile(cur.getMobile());
			regBean.setUnionId(wxId);
			regBean.setName("Lily"+TestDataManager.getRandomNum(10));
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();			
			Logger.verifyEquals("登录成功", regCall.getString("SuccessMessage"), "验证返回的Message信息");
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			verifyDBBind(uid,regBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	11.三方联合登入时传入已存在已解绑第三方账号,第三方手机号是码头已存在已绑定第三方手机号,失败
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_011() {
		Logger.start(true,"三方联合登入时传入已存在已解绑第三方账号,第三方手机号是码头已存在已绑定第三方手机号,失败");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			BindThirdPartyUserReq third=JUserCallService.initBindThirdUserReq(uid);
			third.setThirdPartyType(ThirdPartyTypeEnum.WeiXin);
			JUserCallService.bindThirdPartyUserCall(third);
			UnBindThirdPartyUserReq ubtrd=new UnBindThirdPartyUserReq();
			ubtrd.setThirdPartyId(third.getThirdPartyId());
			ubtrd.setUserId(uid);
			ubtrd.setThirdPartyType(ThirdPartyTypeEnum.WeiXin);
			JUserCallService.UnBindThirdPartyUserCall(ubtrd);
			
			CreateUserReq cur2 = new CreateUserReq();
			cur2 = JUserCallService.initCreateUserBean(cur2);
			int uid2= JUserCallService.createUserCall(cur2);
			BindThirdPartyUserReq third2=JUserCallService.initBindThirdUserReq(uid2);
			third2.setThirdPartyType(ThirdPartyTypeEnum.WeiXin);
			JUserCallService.bindThirdPartyUserCall(third2);
			
			
			regBean.setMobile(cur2.getMobile());
			regBean.setUnionId(wxId);
			regBean.setName("Lily"+TestDataManager.getRandomNum(10));
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();			
			Logger.verifyIsContains("该手机号码已经绑定过微信了，换一个试试吧~", regCall.getString("LastErrorMessage"), "验证返回的LastErrorMessage信息");
			Logger.verifyEquals("400", regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("false", regCall.getString("Success"), "验证是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	12.三方联合登入时传入已存在未解绑第三方账号,码头用户手机不为空第三方手机号为空,登入成功	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_012() {
		Logger.start(true,"三方联合登入时传入已存在未解绑第三方账号,码头用户手机不为空第三方手机号为空,登入成功");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			BindThirdPartyUserReq third=JUserCallService.initBindThirdUserReq(uid);
			third.setThirdPartyType(ThirdPartyTypeEnum.WeiXin);
			third.setThirdPartyId(wxId);
			JUserCallService.bindThirdPartyUserCall(third);
			
			regBean.setUnionId(wxId);
			regBean.setName("Lily"+TestDataManager.getRandomNum(10));
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();			
			
			Logger.verifyEquals("login", regCall.getResult().get("Remark"), "验证Remark信息");
			Logger.verifyEquals("200" ,regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_013() {
		Logger.start(false,"不输入Ali用户Id，用户创建失败");
		try {
			regBean.setName("Lily");
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();			
			Logger.verifyEquals("false", regCall.getString("Success"), "验证是否成功");
			Logger.verifyEquals(ECode.ERROR400, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyIsContains("错误的请求参数|无效的第三方用户Id", regCall.getString("LastErrorMessage"), "验证返回的Message信息");
			Logger.verifyEquals("IllegalArgument", regCall.getResult().get("VerifyCode"), "验证凭据");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_014(){
		Logger.start(true,"不输入真实用户名，用户创建成功");
		try {
			String wxId = TestDataManager.getRandomNum(7);
			regBean.setUnionId(wxId);
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regBean.setClientIp("120.1.1.1");
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setMobile(TestDataManager.getPhoneNum());
			regCall.setData(regBean);
			regCall.callService();	
			int nuid=regCall.getJsonObject().get("Result").getAsJsonObject().get("UserId").getAsInt();
			Logger.verifyEquals("注册成功", regCall.getString("SuccessMessage"), "验证返回的Message信息");
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			
			
			Logger.verifyEquals("new", regCall.getResult().get("Remark"), "验证Remark信息");
			Logger.verifyEquals("Success", regCall.getResult().get("VerifyCode"), "验证凭据");
			verifyDB(nuid,regBean);
//			Logger.verifyEquals("登录ID不能为空", regCall.getString("LastErrorMessage"), "验证返回的Message信息");
//			Logger.verifyEquals(ECode.ERROR400, regCall.getString("ResponseCode"), "验证code");
//			Logger.verifyEquals("false", regCall.getString("Success"), "验证是否成功");
//			Logger.verifyEquals("LoginNameEmpty", regCall.getResult().get("VerifyCode"), "验证凭据");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_015(){
		Logger.start(false,"不输入手机，用户创建失败");
		try {
			String wxId = TestDataManager.getRandomNum(7);
			regBean.setUnionId(wxId);
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setClientIp("120.1.1.1");
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regCall.setData(regBean);
			regCall.callService();	
			
			Logger.verifyEquals("为了您的账户安全，请绑定你的手机号码", regCall.getString("LastErrorMessage"), "验证返回的Message信息");
			Logger.verifyEquals(ECode.ERROR400, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("false", regCall.getString("Success"), "验证是否成功");
			Logger.verifyEquals("NeedBindMobile", regCall.getResult().get("VerifyCode"), "验证凭证");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_016() {
		Logger.start(true,"微信第一次授权,创建用户成功,用户名长度大于20");
		try {
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			
			String phone = TestDataManager.getPhoneNum();
			
			Logger.comment("绑定手机号，注册微信");
			regBean.setUnionId(wxId);
			regBean.setName("regwx_"+TestDataManager.getRandomNum(20));
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setMobile(phone);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();			
			Logger.verifyEquals("new", regCall.getResult().get("Remark"), "验证Remark信息");
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P3.class)
	@TestCase
	@Ignore
	//20181011 不会报错 自动重新生成
	public void Tc_WeiXinUserRequestDto_017() {
		Logger.start(false,"微信第一次授权,创建用户失败,用户名长度大于100");
		try {
			String wxId = "wx_"+TestDataManager.getRandomNum(101);
			
			String phone = TestDataManager.getPhoneNum();
			
			Logger.comment("绑定手机号，注册微信");
			regBean.setUnionId(wxId);
			regBean.setName("regwx_"+TestDataManager.getRandomNum(101));
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setMobile(phone);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();			
			String VerifyCode=regCall.getJsonObject().get("Result").getAsJsonObject().get("VerifyCode").getAsString();
			Logger.verifyEquals("LoginNameLengthError", VerifyCode, "验证返回的LoginNameLengthError信息");
			Logger.verifyEquals("400", regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("false", regCall.getString("Success"), "验证是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_018() {
		Logger.start(true,"传入TokenSource为sellerapp用户注册成功JIRACONN-2123");
		try {
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			
			String phone = TestDataManager.getPhoneNum();
			if(JUserCallService.mobileExists(phone)){
				phone=TestDataManager.getPhoneNum();
			}
			Logger.comment("绑定手机号，注册微信");
			regBean.setUnionId(wxId);
			regBean.setName("regwx_"+TestDataManager.getRandomNum(6));
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setMobile(phone);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regBean.setDeviceId(TestDataManager.getRandomUUID().toString());
			regBean.setEquimentid(TestDataManager.getRandomUUID().toString());
			regBean.setTokenSource("sellerapp");
			regCall.setData(regBean);
			regCall.callService();			
			Logger.verifyEquals("注册成功", regCall.getString("SuccessMessage"), "验证返回的Message信息");
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_019() {
		Logger.start(true,"传入TokenSource为app用户注册成功JIRACONN-2123");
		try {
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			
			String phone = TestDataManager.getPhoneNum();
			
			Logger.comment("绑定手机号，注册微信");
			regBean.setUnionId(wxId);
			regBean.setName("regwx_"+TestDataManager.getRandomNum(6));
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setClientIp("120.1.1.1");
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setMobile(phone);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regBean.setDeviceId(TestDataManager.getRandomUUID().toString());
			regBean.setEquimentid(TestDataManager.getRandomUUID().toString());
			regBean.setTokenSource("app");
			regCall.setData(regBean);
			regCall.callService();			
			Logger.verifyEquals("注册成功", regCall.getString("SuccessMessage"), "验证返回的Message信息");
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_020() {
		Logger.start(false,"特殊字符用户名失败JIRACONN-2522");
		try {
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			
			String phone = TestDataManager.getPhoneNum();
			
			Logger.comment("绑定手机号，注册微信");
			regBean.setUnionId(wxId+"!");
			regBean.setName("~!@#$%^&*");
			
			regBean.setRegSource(AppSourceEnum.App);
			
			regBean.setClientIp("120.1.1.1");
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setMobile(phone);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regBean.setDeviceId(TestDataManager.getRandomUUID().toString());
			regBean.setEquimentid(TestDataManager.getRandomUUID().toString());
			regCall.setData(regBean);
			regCall.callService();			
//			String VerifyCode=regCall.getJsonObject().get("Result").getAsJsonObject().get("VerifyCode").getAsString();
//			Logger.verifyEquals("LoginNameContainSQLSensitiveCode", VerifyCode, "验证返回的LoginNameContextError信息");
			Logger.verifyEquals(ECode.ERROR400, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("false", regCall.getString("Success"), "验证是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_021() {
		Logger.start(true,"第三方账户已存在，AppSource不同，绑定账号");
		try {
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			String phone = TestDataManager.getPhoneNum();
			Logger.comment("绑定手机号，注册微信");
			regBean.setUnionId(wxId);
			regBean.setName("regwx_"+TestDataManager.getRandomNum(6));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setMobile(phone);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regBean.setDeviceId(TestDataManager.getRandomUUID().toString());
			regBean.setEquimentid(TestDataManager.getRandomUUID().toString());
			regBean.setTokenSource("tokenSource");
//			regBean.setTSource(TerminalSourceEnum.PC);
			regBean.setCountry("Country");
			regBean.setProvince("Province");
			regBean.setCity("City");
			regBean.setHeadimgurl("Headimgurl");
			regBean.setTSource(TerminalSourceEnum.Android);
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regCall.setData(regBean);
			regCall.callService();	
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			
			regBean.setRegSource(AppSourceEnum.Wap);
			regCall.setData(regBean);
			regCall.callService();	
			
			Integer uid=regCall.getJsonObject().get("Result").getAsJsonObject().get("UserId").getAsInt();
			Logger.comment("和数据库进行数据校验");
			verifyDB(uid,regBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_022() {
		Logger.start(true,"微信注册成功后删除账号手机，然后换渠道带手机号联登,成功,手机入库");
		try {
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			String phone = TestDataManager.getPhoneNum();
			Logger.comment("绑定手机号，注册微信");
			regBean.setUnionId(wxId);
			regBean.setName("regwx_"+TestDataManager.getRandomNum(6));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setMobile(phone);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regBean.setDeviceId(TestDataManager.getRandomUUID().toString());
			regBean.setEquimentid(TestDataManager.getRandomUUID().toString());
			regBean.setTokenSource("tokenSource");
//			regBean.setTSource(TerminalSourceEnum.PC);
			regBean.setCountry("Country");
			regBean.setProvince("Province");
			regBean.setCity("City");
			regBean.setHeadimgurl("Headimgurl");
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regCall.setData(regBean);
			regCall.callService();	
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			Integer uid=regCall.getJsonObject().get("Result").getAsJsonObject().get("UserId").getAsInt();
			Logger.comment("移除手机号");
			new JUserWapper().removeMoblie(uid);
			
			regBean.setRegSource(AppSourceEnum.Wap);
			regCall.callService();	
			
			Logger.comment("和数据库进行数据校验");
			verifyDB(uid,regBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_023() {
		Logger.start(true,"微信第一次授权,创建用户成功,渠道为wap时验证im的wxusermapping");
		try {
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			String phone = TestDataManager.getPhoneNum();
			Logger.comment("绑定手机号，注册微信");
			regBean.setUnionId(wxId);
			regBean.setName("regwx_"+TestDataManager.getRandomNum(6));
			regBean.setRegSource(AppSourceEnum.Wap);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setMobile(phone);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regBean.setDeviceId(TestDataManager.getRandomUUID().toString());
			regBean.setEquimentid(TestDataManager.getRandomUUID().toString());
			regBean.setTokenSource("tokenSource");
//			regBean.setTSource(TerminalSourceEnum.PC);
			regBean.setCountry("Country");
			regBean.setProvince("Province");
			regBean.setCity("City");
			regBean.setHeadimgurl("Headimgurl");
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regCall.setData(regBean);
			regCall.callService();	
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			Integer uid=regCall.getJsonObject().get("Result").getAsJsonObject().get("UserId").getAsInt();
			Logger.comment("和数据库进行数据校验");
			verifyDB(uid,regBean);
			LoginLog loginLog = new JUserWapper().selectLastLoginLogByUid(uid).get(0);
			Logger.verifyEquals(regBean.getName(), loginLog.getLoginId(), "验证LoginLog表中LoginId");
			Logger.verifyEquals(regBean.getClientIp(), loginLog.getClientIp(), "验证LoginLog表中ClientIp");
			// 码头登陆的为0
			Logger.verifyEquals(6, loginLog.getChannelSource(), "验证LoginLog表中ChannelSource");
			Logger.verifyEquals(2, loginLog.getTerminalSource(), "验证LoginLog表中TerminalSource");
			Logger.verifyEquals(regBean.getDeviceId(), loginLog.getDeviceId(), "验证LoginLog表中DeviceId");
			Logger.verifyNotNull(loginLog.getServerIP(), "验证LoginLog表中ServerIP");

			if (regCall.getString("Success").equals("true")) {
				Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(200, loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			} 
			// 风控返回
//			 Logger.verifyNotNull(loginLog.getIpArea(), "验证LoginLog表中IpArea");
			Logger.verifyNotNull(loginLog.getCreateTime(), "验证LoginLog表中CreateTime");
			Logger.verifyEquals(0, loginLog.getUserType(), "验证LoginLog表中UserType");
			//20180613 数据不落地
//			Thread.sleep(1000);
//			List<Map> m=new JUserWapper().selectWxUserMapping(uid);
//			Logger.debug(m);
//			Logger.verifyNotEquals(0,m.size(), "验证WxUserMapping有数据");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_024() {
		Logger.start(true,"第三方联合登入时传入已锁定存在账号,失败JIRACONN-9521");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			
			JUserCallService.lockUsers(uid);
			
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			
			regBean.setMobile(cur.getMobile());
			regBean.setUnionId(wxId);
			regBean.setName("Lily"+TestDataManager.getRandomNum(10));
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setClientIp("120.1.1.1");
			
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();			
			Logger.verifyEquals("UserLocked", regCall.getResult().get("VerifyCode"), "验证VerifyCode信息");
			Logger.verifyEquals("400", regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("false", regCall.getString("Success"), "验证是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_025() {
		Logger.start(true,"第三方联合登入时传入已注销存在账号,失败JIRACONN-9521");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			int uid = JUserCallService.createUserCall(cur);
			
			new JUserWapper().updateUserState(uid, 2);
			
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			
			regBean.setMobile(cur.getMobile());
			regBean.setUnionId(wxId);
			regBean.setName("Lily"+TestDataManager.getRandomNum(10));
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setClientIp("120.1.1.1");
			
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regCall.setData(regBean);
			regCall.callService();			
			Logger.verifyEquals("UserLocked", regCall.getResult().get("VerifyCode"), "验证VerifyCode信息");
			Logger.verifyEquals("400", regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("false", regCall.getString("Success"), "验证是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_026() {
		Logger.start(true,"不同的手机用户注册同一个微信的不同渠道失败");
		try {
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			String phone = TestDataManager.getPhoneNum();
			Logger.comment("绑定手机号，注册微信");
			regBean.setUnionId(wxId);
			regBean.setName("regwx_"+TestDataManager.getRandomNum(6));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setMobile(phone);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regBean.setDeviceId(TestDataManager.getRandomUUID().toString());
			regBean.setEquimentid(TestDataManager.getRandomUUID().toString());
			regBean.setTokenSource("tokenSource");
//			regBean.setTSource(TerminalSourceEnum.PC);
			regBean.setCountry("Country");
			regBean.setProvince("Province");
			regBean.setCity("City");
			regBean.setHeadimgurl("Headimgurl");
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regCall.setData(regBean);
			regCall.callService();	
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			regBean.setMobile(TestDataManager.getPhoneNum());
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regBean.setRegSource(AppSourceEnum.WxApp);
			regCall.callService();	
			Logger.verifyEquals("400", regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("false", regCall.getString("Success"), "验证是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_027() {
		Logger.start(true,"微信第一次授权,创建用户成功,AppLive11来自码头App直播版本");
		try {
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			String phone = TestDataManager.getPhoneNum();
			Logger.comment("绑定手机号，注册微信");
			regBean.setUnionId(wxId);
			regBean.setName("regwx_"+TestDataManager.getRandomNum(6));
			regBean.setRegSource(AppSourceEnum.AppLive);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setMobile(phone);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regBean.setDeviceId(TestDataManager.getRandomUUID().toString());
			regBean.setEquimentid(TestDataManager.getRandomUUID().toString());
			regBean.setTokenSource("tokenSource");
//			regBean.setTSource(TerminalSourceEnum.PC);
			regBean.setCountry("Country");
			regBean.setProvince("Province");
			regBean.setCity("City");
			regBean.setHeadimgurl("Headimgurl");
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regCall.setData(regBean);
			regCall.callService();	
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			Integer uid=regCall.getJsonObject().get("Result").getAsJsonObject().get("UserId").getAsInt();
			Logger.comment("和数据库进行数据校验");
			verifyDB(uid,regBean);
			LoginLog loginLog = new JUserWapper().selectLastLoginLogByUid(uid).get(0);
			Logger.verifyEquals(regBean.getName(), loginLog.getLoginId(), "验证LoginLog表中LoginId");
			Logger.verifyEquals(regBean.getClientIp(), loginLog.getClientIp(), "验证LoginLog表中ClientIp");
			// 码头登陆的为0
			Logger.verifyEquals(6, loginLog.getChannelSource(), "验证LoginLog表中ChannelSource");
			Logger.verifyEquals(2, loginLog.getTerminalSource(), "验证LoginLog表中TerminalSource");
			Logger.verifyEquals(regBean.getDeviceId(), loginLog.getDeviceId(), "验证LoginLog表中DeviceId");
			Logger.verifyNotNull(loginLog.getServerIP(), "验证LoginLog表中ServerIP");

			if (regCall.getString("Success").equals("true")) {
				Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(200, loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			} 
			// 风控返回
//			 Logger.verifyNotNull(loginLog.getIpArea(), "验证LoginLog表中IpArea");
			Logger.verifyNotNull(loginLog.getCreateTime(), "验证LoginLog表中CreateTime");
			Logger.verifyEquals(0, loginLog.getUserType(), "验证LoginLog表中UserType");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_028() {
		Logger.start(true,"微信用户第二次登入头像地址变更,更新头像");
		try {
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			String phone = TestDataManager.getPhoneNum();
			Logger.comment("绑定手机号，注册微信");
			regBean.setUnionId(wxId);
			regBean.setName("regwx_"+TestDataManager.getRandomNum(6));
			regBean.setRegSource(AppSourceEnum.App);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setMobile(phone);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regBean.setDeviceId(TestDataManager.getRandomUUID().toString());
			regBean.setEquimentid(TestDataManager.getRandomUUID().toString());
			regBean.setTokenSource("tokenSource");
//			regBean.setTSource(TerminalSourceEnum.PC);
			regBean.setCountry("Country");
			regBean.setProvince("Province");
			regBean.setCity("City");
			regBean.setHeadimgurl("Headimgurl");
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regCall.setData(regBean);
			regCall.callService();	
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			Integer uid=regCall.getJsonObject().get("Result").getAsJsonObject().get("UserId").getAsInt();
			Logger.comment("和数据库进行数据校验");
			verifyDB(uid,regBean);
			LoginLog loginLog = new JUserWapper().selectLastLoginLogByUid(uid).get(0);
			Logger.verifyEquals(regBean.getName(), loginLog.getLoginId(), "验证LoginLog表中LoginId");
			Logger.verifyEquals(regBean.getClientIp(), loginLog.getClientIp(), "验证LoginLog表中ClientIp");
			// 码头登陆的为0
			Logger.verifyEquals(6, loginLog.getChannelSource(), "验证LoginLog表中ChannelSource");
			Logger.verifyEquals(2, loginLog.getTerminalSource(), "验证LoginLog表中TerminalSource");
			Logger.verifyEquals(regBean.getDeviceId(), loginLog.getDeviceId(), "验证LoginLog表中DeviceId");
			Logger.verifyNotNull(loginLog.getServerIP(), "验证LoginLog表中ServerIP");

			if (regCall.getString("Success").equals("true")) {
				Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(200, loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			} 
			// 风控返回
//			 Logger.verifyNotNull(loginLog.getIpArea(), "验证LoginLog表中IpArea");
			Logger.verifyNotNull(loginLog.getCreateTime(), "验证LoginLog表中CreateTime");
			Logger.verifyEquals(0, loginLog.getUserType(), "验证LoginLog表中UserType");
			
			regBean.setHeadimgurl("Headimgurl2");
			regCall.callService();	
			Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
			verifyDB(uid,regBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_029() {
		Logger.start(true,"微信第一次授权,创建用户成功,31来自GlobalApp");
		try {
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			String phone = TestDataManager.getPhoneNum();
			Logger.comment("绑定手机号，注册微信");
			regBean.setUnionId(wxId);
			regBean.setName("regwx_"+TestDataManager.getRandomNum(6));
			regBean.setRegSource(AppSourceEnum.GlobalApp);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setMobile(phone);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regBean.setDeviceId(TestDataManager.getRandomUUID().toString());
			regBean.setEquimentid(TestDataManager.getRandomUUID().toString());
			regBean.setTokenSource("tokenSource");
//			regBean.setTSource(TerminalSourceEnum.PC);
			regBean.setCountry("Country");
			regBean.setProvince("Province");
			regBean.setCity("City");
			regBean.setHeadimgurl("Headimgurl");
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regCall.setData(regBean);
			regCall.callService();	
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			Integer uid=regCall.getJsonObject().get("Result").getAsJsonObject().get("UserId").getAsInt();
			Logger.comment("和数据库进行数据校验");
			verifyDB(uid,regBean);
			LoginLog loginLog = new JUserWapper().selectLastLoginLogByUid(uid).get(0);
			Logger.verifyEquals(regBean.getName(), loginLog.getLoginId(), "验证LoginLog表中LoginId");
			Logger.verifyEquals(regBean.getClientIp(), loginLog.getClientIp(), "验证LoginLog表中ClientIp");
			// 码头登陆的为0
			Logger.verifyEquals(6, loginLog.getChannelSource(), "验证LoginLog表中ChannelSource");
			Logger.verifyEquals(2, loginLog.getTerminalSource(), "验证LoginLog表中TerminalSource");
			Logger.verifyEquals(regBean.getDeviceId(), loginLog.getDeviceId(), "验证LoginLog表中DeviceId");
			Logger.verifyNotNull(loginLog.getServerIP(), "验证LoginLog表中ServerIP");

			if (regCall.getString("Success").equals("true")) {
				Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(200, loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			} 
			// 风控返回
//			 Logger.verifyNotNull(loginLog.getIpArea(), "验证LoginLog表中IpArea");
			Logger.verifyNotNull(loginLog.getCreateTime(), "验证LoginLog表中CreateTime");
			Logger.verifyEquals(0, loginLog.getUserType(), "验证LoginLog表中UserType");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_030() {
		Logger.start(true,"微信第一次授权,创建用户成功,32来自GlobalWxApp");
		try {
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			String phone = TestDataManager.getPhoneNum();
			Logger.comment("绑定手机号，注册微信");
			regBean.setUnionId(wxId);
			regBean.setName("regwx_"+TestDataManager.getRandomNum(6));
			regBean.setRegSource(AppSourceEnum.GlobalWxApp);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setMobile(phone);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regBean.setDeviceId(TestDataManager.getRandomUUID().toString());
			regBean.setEquimentid(TestDataManager.getRandomUUID().toString());
			regBean.setTokenSource("tokenSource");
//			regBean.setTSource(TerminalSourceEnum.PC);
			regBean.setCountry("Country");
			regBean.setProvince("Province");
			regBean.setCity("City");
			regBean.setHeadimgurl("Headimgurl");
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regCall.setData(regBean);
			regCall.callService();	
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			Integer uid=regCall.getJsonObject().get("Result").getAsJsonObject().get("UserId").getAsInt();
			Logger.comment("和数据库进行数据校验");
			verifyDB(uid,regBean);
			LoginLog loginLog = new JUserWapper().selectLastLoginLogByUid(uid).get(0);
			Logger.verifyEquals(regBean.getName(), loginLog.getLoginId(), "验证LoginLog表中LoginId");
			Logger.verifyEquals(regBean.getClientIp(), loginLog.getClientIp(), "验证LoginLog表中ClientIp");
			// 码头登陆的为0
			Logger.verifyEquals(6, loginLog.getChannelSource(), "验证LoginLog表中ChannelSource");
			Logger.verifyEquals(2, loginLog.getTerminalSource(), "验证LoginLog表中TerminalSource");
			Logger.verifyEquals(regBean.getDeviceId(), loginLog.getDeviceId(), "验证LoginLog表中DeviceId");
			Logger.verifyNotNull(loginLog.getServerIP(), "验证LoginLog表中ServerIP");

			if (regCall.getString("Success").equals("true")) {
				Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(200, loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			} 
			// 风控返回
//			 Logger.verifyNotNull(loginLog.getIpArea(), "验证LoginLog表中IpArea");
			Logger.verifyNotNull(loginLog.getCreateTime(), "验证LoginLog表中CreateTime");
			Logger.verifyEquals(0, loginLog.getUserType(), "验证LoginLog表中UserType");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_WeiXinUserRequestDto_031() {
		Logger.start(true,"微信第一次授权,创建用户成功,32来自GlobalWxApp,然后切换开放平台uid变更-可以登入");
		try {
			String wxId = "wx_"+TestDataManager.getRandomNum(10);
			String phone = TestDataManager.getPhoneNum();
			Logger.comment("绑定手机号，注册微信");
			regBean.setUnionId(wxId);
			regBean.setName("regwx_"+TestDataManager.getRandomNum(6));
			regBean.setRegSource(AppSourceEnum.GlobalWxApp);
			regBean.setTSource(TerminalSourceEnum.IOS);
			regBean.setClientIp("120.1.1.1");
			
			regBean.setMobile(phone);
			regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
			regBean.setDeviceId(TestDataManager.getRandomUUID().toString());
			regBean.setEquimentid(TestDataManager.getRandomUUID().toString());
			regBean.setTokenSource("tokenSource");
//			regBean.setTSource(TerminalSourceEnum.PC);
			regBean.setCountry("Country");
			regBean.setProvince("Province");
			regBean.setCity("City");
			regBean.setHeadimgurl("Headimgurl");
			regBean.setOId( "openId_"+TestDataManager.getRandomNum(10));
			regCall.setData(regBean);
			regCall.callService();	
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
			Integer uid=regCall.getJsonObject().get("Result").getAsJsonObject().get("UserId").getAsInt();
			Logger.comment("和数据库进行数据校验");
			verifyDB(uid,regBean);
			LoginLog loginLog = new JUserWapper().selectLastLoginLogByUid(uid).get(0);
			Logger.verifyEquals(regBean.getName(), loginLog.getLoginId(), "验证LoginLog表中LoginId");
			Logger.verifyEquals(regBean.getClientIp(), loginLog.getClientIp(), "验证LoginLog表中ClientIp");
			// 码头登陆的为0
			Logger.verifyEquals(6, loginLog.getChannelSource(), "验证LoginLog表中ChannelSource");
			Logger.verifyEquals(2, loginLog.getTerminalSource(), "验证LoginLog表中TerminalSource");
			Logger.verifyEquals(regBean.getDeviceId(), loginLog.getDeviceId(), "验证LoginLog表中DeviceId");
			Logger.verifyNotNull(loginLog.getServerIP(), "验证LoginLog表中ServerIP");

			if (regCall.getString("Success").equals("true")) {
				Logger.verifyIsContains("登录成功", loginLog.getResponseDesc(), "验证LoginLog表中ResponseDesc");
				Logger.verifyEquals(200, loginLog.getResponseCode(), "验证LoginLog表中ResponseCode");

			} 
			// 风控返回
//			 Logger.verifyNotNull(loginLog.getIpArea(), "验证LoginLog表中IpArea");
			Logger.verifyNotNull(loginLog.getCreateTime(), "验证LoginLog表中CreateTime");
			Logger.verifyEquals(0, loginLog.getUserType(), "验证LoginLog表中UserType");
			
			regBean.setUnionId("uId_"+TestDataManager.getRandomNum(10));
			regCall.callService();	
			Logger.verifyEquals(ECode.SUCCESS, regCall.getString("ResponseCode"), "验证code");
			Logger.verifyEquals("true", regCall.getString("Success"), "验证是否成功");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}